package com.das.mechanic_base.gen;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.das.mechanic_base.widget.ProcessConverter;
import com.das.mechanic_base.widget.StringConverter;
import java.util.List;

import com.das.mechanic_base.bean.siveprocess.SiveReportBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "SIVE_REPORT_BEAN".
*/
public class SiveReportBeanDao extends AbstractDao<SiveReportBean, Long> {

    public static final String TABLENAME = "SIVE_REPORT_BEAN";

    /**
     * Properties of entity SiveReportBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property CurrentId = new Property(1, String.class, "currentId", false, "CURRENT_ID");
        public final static Property Answered = new Property(2, boolean.class, "answered", false, "ANSWERED");
        public final static Property StandardOrNot = new Property(3, boolean.class, "standardOrNot", false, "STANDARD_OR_NOT");
        public final static Property Name = new Property(4, String.class, "name", false, "NAME");
        public final static Property Sn = new Property(5, String.class, "sn", false, "SN");
        public final static Property TotalPath = new Property(6, long.class, "totalPath", false, "TOTAL_PATH");
        public final static Property ProcedureAmount = new Property(7, long.class, "procedureAmount", false, "PROCEDURE_AMOUNT");
        public final static Property AnswerCount = new Property(8, long.class, "answerCount", false, "ANSWER_COUNT");
        public final static Property TechanicsSnList = new Property(9, String.class, "techanicsSnList", false, "TECHANICS_SN_LIST");
        public final static Property SiveProBeanList = new Property(10, String.class, "siveProBeanList", false, "SIVE_PRO_BEAN_LIST");
    }

    private final StringConverter techanicsSnListConverter = new StringConverter();
    private final ProcessConverter siveProBeanListConverter = new ProcessConverter();

    public SiveReportBeanDao(DaoConfig config) {
        super(config);
    }
    
    public SiveReportBeanDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"SIVE_REPORT_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"CURRENT_ID\" TEXT," + // 1: currentId
                "\"ANSWERED\" INTEGER NOT NULL ," + // 2: answered
                "\"STANDARD_OR_NOT\" INTEGER NOT NULL ," + // 3: standardOrNot
                "\"NAME\" TEXT," + // 4: name
                "\"SN\" TEXT," + // 5: sn
                "\"TOTAL_PATH\" INTEGER NOT NULL ," + // 6: totalPath
                "\"PROCEDURE_AMOUNT\" INTEGER NOT NULL ," + // 7: procedureAmount
                "\"ANSWER_COUNT\" INTEGER NOT NULL ," + // 8: answerCount
                "\"TECHANICS_SN_LIST\" TEXT," + // 9: techanicsSnList
                "\"SIVE_PRO_BEAN_LIST\" TEXT);"); // 10: siveProBeanList
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"SIVE_REPORT_BEAN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, SiveReportBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String currentId = entity.getCurrentId();
        if (currentId != null) {
            stmt.bindString(2, currentId);
        }
        stmt.bindLong(3, entity.getAnswered() ? 1L: 0L);
        stmt.bindLong(4, entity.getStandardOrNot() ? 1L: 0L);
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(5, name);
        }
 
        String sn = entity.getSn();
        if (sn != null) {
            stmt.bindString(6, sn);
        }
        stmt.bindLong(7, entity.getTotalPath());
        stmt.bindLong(8, entity.getProcedureAmount());
        stmt.bindLong(9, entity.getAnswerCount());
 
        List techanicsSnList = entity.getTechanicsSnList();
        if (techanicsSnList != null) {
            stmt.bindString(10, techanicsSnListConverter.convertToDatabaseValue(techanicsSnList));
        }
 
        List siveProBeanList = entity.getSiveProBeanList();
        if (siveProBeanList != null) {
            stmt.bindString(11, siveProBeanListConverter.convertToDatabaseValue(siveProBeanList));
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, SiveReportBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String currentId = entity.getCurrentId();
        if (currentId != null) {
            stmt.bindString(2, currentId);
        }
        stmt.bindLong(3, entity.getAnswered() ? 1L: 0L);
        stmt.bindLong(4, entity.getStandardOrNot() ? 1L: 0L);
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(5, name);
        }
 
        String sn = entity.getSn();
        if (sn != null) {
            stmt.bindString(6, sn);
        }
        stmt.bindLong(7, entity.getTotalPath());
        stmt.bindLong(8, entity.getProcedureAmount());
        stmt.bindLong(9, entity.getAnswerCount());
 
        List techanicsSnList = entity.getTechanicsSnList();
        if (techanicsSnList != null) {
            stmt.bindString(10, techanicsSnListConverter.convertToDatabaseValue(techanicsSnList));
        }
 
        List siveProBeanList = entity.getSiveProBeanList();
        if (siveProBeanList != null) {
            stmt.bindString(11, siveProBeanListConverter.convertToDatabaseValue(siveProBeanList));
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public SiveReportBean readEntity(Cursor cursor, int offset) {
        SiveReportBean entity = new SiveReportBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // currentId
            cursor.getShort(offset + 2) != 0, // answered
            cursor.getShort(offset + 3) != 0, // standardOrNot
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // name
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // sn
            cursor.getLong(offset + 6), // totalPath
            cursor.getLong(offset + 7), // procedureAmount
            cursor.getLong(offset + 8), // answerCount
            cursor.isNull(offset + 9) ? null : techanicsSnListConverter.convertToEntityProperty(cursor.getString(offset + 9)), // techanicsSnList
            cursor.isNull(offset + 10) ? null : siveProBeanListConverter.convertToEntityProperty(cursor.getString(offset + 10)) // siveProBeanList
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, SiveReportBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setCurrentId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setAnswered(cursor.getShort(offset + 2) != 0);
        entity.setStandardOrNot(cursor.getShort(offset + 3) != 0);
        entity.setName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setSn(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setTotalPath(cursor.getLong(offset + 6));
        entity.setProcedureAmount(cursor.getLong(offset + 7));
        entity.setAnswerCount(cursor.getLong(offset + 8));
        entity.setTechanicsSnList(cursor.isNull(offset + 9) ? null : techanicsSnListConverter.convertToEntityProperty(cursor.getString(offset + 9)));
        entity.setSiveProBeanList(cursor.isNull(offset + 10) ? null : siveProBeanListConverter.convertToEntityProperty(cursor.getString(offset + 10)));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(SiveReportBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(SiveReportBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(SiveReportBean entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
